<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>dgegv.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(188, 143, 143);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      SUBROUTINE <a name="DGEGV.1"></a><a href="dgegv.f.html#DGEGV.1">DGEGV</a>( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR, ALPHAI,
     $                  BETA, VL, LDVL, VR, LDVR, WORK, LWORK, INFO )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  -- LAPACK driver routine (version 3.1) --
</span><span class="comment">*</span><span class="comment">     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
</span><span class="comment">*</span><span class="comment">     November 2006
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      CHARACTER          JOBVL, JOBVR
      INTEGER            INFO, LDA, LDB, LDVL, LDVR, LWORK, N
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      DOUBLE PRECISION   A( LDA, * ), ALPHAI( * ), ALPHAR( * ),
     $                   B( LDB, * ), BETA( * ), VL( LDVL, * ),
     $                   VR( LDVR, * ), WORK( * )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  This routine is deprecated and has been replaced by routine <a name="DGGEV.21"></a><a href="dggev.f.html#DGGEV.1">DGGEV</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  <a name="DGEGV.23"></a><a href="dgegv.f.html#DGEGV.1">DGEGV</a> computes the eigenvalues and, optionally, the left and/or right
</span><span class="comment">*</span><span class="comment">  eigenvectors of a real matrix pair (A,B).
</span><span class="comment">*</span><span class="comment">  Given two square matrices A and B,
</span><span class="comment">*</span><span class="comment">  the generalized nonsymmetric eigenvalue problem (GNEP) is to find the
</span><span class="comment">*</span><span class="comment">  eigenvalues lambda and corresponding (non-zero) eigenvectors x such
</span><span class="comment">*</span><span class="comment">  that
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     A*x = lambda*B*x.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  An alternate form is to find the eigenvalues mu and corresponding
</span><span class="comment">*</span><span class="comment">  eigenvectors y such that
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     mu*A*y = B*y.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  These two forms are equivalent with mu = 1/lambda and x = y if
</span><span class="comment">*</span><span class="comment">  neither lambda nor mu is zero.  In order to deal with the case that
</span><span class="comment">*</span><span class="comment">  lambda or mu is zero or small, two values alpha and beta are returned
</span><span class="comment">*</span><span class="comment">  for each eigenvalue, such that lambda = alpha/beta and
</span><span class="comment">*</span><span class="comment">  mu = beta/alpha.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  The vectors x and y in the above equations are right eigenvectors of
</span><span class="comment">*</span><span class="comment">  the matrix pair (A,B).  Vectors u and v satisfying
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     u**H*A = lambda*u**H*B  or  mu*v**H*A = v**H*B
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  are left eigenvectors of (A,B).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Note: this routine performs &quot;full balancing&quot; on A and B -- see
</span><span class="comment">*</span><span class="comment">  &quot;Further Details&quot;, below.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Arguments
</span><span class="comment">*</span><span class="comment">  =========
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  JOBVL   (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          = 'N':  do not compute the left generalized eigenvectors;
</span><span class="comment">*</span><span class="comment">          = 'V':  compute the left generalized eigenvectors (returned
</span><span class="comment">*</span><span class="comment">                  in VL).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  JOBVR   (input) CHARACTER*1
</span><span class="comment">*</span><span class="comment">          = 'N':  do not compute the right generalized eigenvectors;
</span><span class="comment">*</span><span class="comment">          = 'V':  compute the right generalized eigenvectors (returned
</span><span class="comment">*</span><span class="comment">                  in VR).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  N       (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The order of the matrices A, B, VL, and VR.  N &gt;= 0.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N)
</span><span class="comment">*</span><span class="comment">          On entry, the matrix A.
</span><span class="comment">*</span><span class="comment">          If JOBVL = 'V' or JOBVR = 'V', then on exit A
</span><span class="comment">*</span><span class="comment">          contains the real Schur form of A from the generalized Schur
</span><span class="comment">*</span><span class="comment">          factorization of the pair (A,B) after balancing.
</span><span class="comment">*</span><span class="comment">          If no eigenvectors were computed, then only the diagonal
</span><span class="comment">*</span><span class="comment">          blocks from the Schur form will be correct.  See <a name="DGGHRD.75"></a><a href="dgghrd.f.html#DGGHRD.1">DGGHRD</a> and
</span><span class="comment">*</span><span class="comment">          <a name="DHGEQZ.76"></a><a href="dhgeqz.f.html#DHGEQZ.1">DHGEQZ</a> for details.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDA     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of A.  LDA &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  B       (input/output) DOUBLE PRECISION array, dimension (LDB, N)
</span><span class="comment">*</span><span class="comment">          On entry, the matrix B.
</span><span class="comment">*</span><span class="comment">          If JOBVL = 'V' or JOBVR = 'V', then on exit B contains the
</span><span class="comment">*</span><span class="comment">          upper triangular matrix obtained from B in the generalized
</span><span class="comment">*</span><span class="comment">          Schur factorization of the pair (A,B) after balancing.
</span><span class="comment">*</span><span class="comment">          If no eigenvectors were computed, then only those elements of
</span><span class="comment">*</span><span class="comment">          B corresponding to the diagonal blocks from the Schur form of
</span><span class="comment">*</span><span class="comment">          A will be correct.  See <a name="DGGHRD.88"></a><a href="dgghrd.f.html#DGGHRD.1">DGGHRD</a> and <a name="DHGEQZ.88"></a><a href="dhgeqz.f.html#DHGEQZ.1">DHGEQZ</a> for details.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDB     (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of B.  LDB &gt;= max(1,N).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  ALPHAR  (output) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">          The real parts of each scalar alpha defining an eigenvalue of
</span><span class="comment">*</span><span class="comment">          GNEP.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  ALPHAI  (output) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">          The imaginary parts of each scalar alpha defining an
</span><span class="comment">*</span><span class="comment">          eigenvalue of GNEP.  If ALPHAI(j) is zero, then the j-th
</span><span class="comment">*</span><span class="comment">          eigenvalue is real; if positive, then the j-th and
</span><span class="comment">*</span><span class="comment">          (j+1)-st eigenvalues are a complex conjugate pair, with
</span><span class="comment">*</span><span class="comment">          ALPHAI(j+1) = -ALPHAI(j).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  BETA    (output) DOUBLE PRECISION array, dimension (N)
</span><span class="comment">*</span><span class="comment">          The scalars beta that define the eigenvalues of GNEP.
</span><span class="comment">*</span><span class="comment">          
</span><span class="comment">*</span><span class="comment">          Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and
</span><span class="comment">*</span><span class="comment">          beta = BETA(j) represent the j-th eigenvalue of the matrix
</span><span class="comment">*</span><span class="comment">          pair (A,B), in one of the forms lambda = alpha/beta or
</span><span class="comment">*</span><span class="comment">          mu = beta/alpha.  Since either lambda or mu may overflow,
</span><span class="comment">*</span><span class="comment">          they should not, in general, be computed.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  VL      (output) DOUBLE PRECISION array, dimension (LDVL,N)
</span><span class="comment">*</span><span class="comment">          If JOBVL = 'V', the left eigenvectors u(j) are stored
</span><span class="comment">*</span><span class="comment">          in the columns of VL, in the same order as their eigenvalues.
</span><span class="comment">*</span><span class="comment">          If the j-th eigenvalue is real, then u(j) = VL(:,j).
</span><span class="comment">*</span><span class="comment">          If the j-th and (j+1)-st eigenvalues form a complex conjugate
</span><span class="comment">*</span><span class="comment">          pair, then
</span><span class="comment">*</span><span class="comment">             u(j) = VL(:,j) + i*VL(:,j+1)
</span><span class="comment">*</span><span class="comment">          and
</span><span class="comment">*</span><span class="comment">            u(j+1) = VL(:,j) - i*VL(:,j+1).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          Each eigenvector is scaled so that its largest component has
</span><span class="comment">*</span><span class="comment">          abs(real part) + abs(imag. part) = 1, except for eigenvectors
</span><span class="comment">*</span><span class="comment">          corresponding to an eigenvalue with alpha = beta = 0, which
</span><span class="comment">*</span><span class="comment">          are set to zero.
</span><span class="comment">*</span><span class="comment">          Not referenced if JOBVL = 'N'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDVL    (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the matrix VL. LDVL &gt;= 1, and
</span><span class="comment">*</span><span class="comment">          if JOBVL = 'V', LDVL &gt;= N.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  VR      (output) DOUBLE PRECISION array, dimension (LDVR,N)
</span><span class="comment">*</span><span class="comment">          If JOBVR = 'V', the right eigenvectors x(j) are stored
</span><span class="comment">*</span><span class="comment">          in the columns of VR, in the same order as their eigenvalues.
</span><span class="comment">*</span><span class="comment">          If the j-th eigenvalue is real, then x(j) = VR(:,j).
</span><span class="comment">*</span><span class="comment">          If the j-th and (j+1)-st eigenvalues form a complex conjugate
</span><span class="comment">*</span><span class="comment">          pair, then
</span><span class="comment">*</span><span class="comment">            x(j) = VR(:,j) + i*VR(:,j+1)
</span><span class="comment">*</span><span class="comment">          and
</span><span class="comment">*</span><span class="comment">            x(j+1) = VR(:,j) - i*VR(:,j+1).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          Each eigenvector is scaled so that its largest component has
</span><span class="comment">*</span><span class="comment">          abs(real part) + abs(imag. part) = 1, except for eigenvalues
</span><span class="comment">*</span><span class="comment">          corresponding to an eigenvalue with alpha = beta = 0, which
</span><span class="comment">*</span><span class="comment">          are set to zero.
</span><span class="comment">*</span><span class="comment">          Not referenced if JOBVR = 'N'.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LDVR    (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The leading dimension of the matrix VR. LDVR &gt;= 1, and
</span><span class="comment">*</span><span class="comment">          if JOBVR = 'V', LDVR &gt;= N.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
</span><span class="comment">*</span><span class="comment">          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  LWORK   (input) INTEGER
</span><span class="comment">*</span><span class="comment">          The dimension of the array WORK.  LWORK &gt;= max(1,8*N).
</span><span class="comment">*</span><span class="comment">          For good performance, LWORK must generally be larger.
</span><span class="comment">*</span><span class="comment">          To compute the optimal value of LWORK, call <a name="ILAENV.159"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a> to get
</span><span class="comment">*</span><span class="comment">          blocksizes (for <a name="DGEQRF.160"></a><a href="dgeqrf.f.html#DGEQRF.1">DGEQRF</a>, <a name="DORMQR.160"></a><a href="dormqr.f.html#DORMQR.1">DORMQR</a>, and <a name="DORGQR.160"></a><a href="dorgqr.f.html#DORGQR.1">DORGQR</a>.)  Then compute:
</span><span class="comment">*</span><span class="comment">          NB  -- MAX of the blocksizes for <a name="DGEQRF.161"></a><a href="dgeqrf.f.html#DGEQRF.1">DGEQRF</a>, <a name="DORMQR.161"></a><a href="dormqr.f.html#DORMQR.1">DORMQR</a>, and <a name="DORGQR.161"></a><a href="dorgqr.f.html#DORGQR.1">DORGQR</a>;
</span><span class="comment">*</span><span class="comment">          The optimal LWORK is:
</span><span class="comment">*</span><span class="comment">              2*N + MAX( 6*N, N*(NB+1) ).
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">          If LWORK = -1, then a workspace query is assumed; the routine
</span><span class="comment">*</span><span class="comment">          only calculates the optimal size of the WORK array, returns
</span><span class="comment">*</span><span class="comment">          this value as the first entry of the WORK array, and no error
</span><span class="comment">*</span><span class="comment">          message related to LWORK is issued by <a name="XERBLA.168"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  INFO    (output) INTEGER
</span><span class="comment">*</span><span class="comment">          = 0:  successful exit
</span><span class="comment">*</span><span class="comment">          &lt; 0:  if INFO = -i, the i-th argument had an illegal value.
</span><span class="comment">*</span><span class="comment">          = 1,...,N:
</span><span class="comment">*</span><span class="comment">                The QZ iteration failed.  No eigenvectors have been
</span><span class="comment">*</span><span class="comment">                calculated, but ALPHAR(j), ALPHAI(j), and BETA(j)
</span><span class="comment">*</span><span class="comment">                should be correct for j=INFO+1,...,N.
</span><span class="comment">*</span><span class="comment">          &gt; N:  errors that usually indicate LAPACK problems:
</span><span class="comment">*</span><span class="comment">                =N+1: error return from <a name="DGGBAL.178"></a><a href="dggbal.f.html#DGGBAL.1">DGGBAL</a>
</span><span class="comment">*</span><span class="comment">                =N+2: error return from <a name="DGEQRF.179"></a><a href="dgeqrf.f.html#DGEQRF.1">DGEQRF</a>
</span><span class="comment">*</span><span class="comment">                =N+3: error return from <a name="DORMQR.180"></a><a href="dormqr.f.html#DORMQR.1">DORMQR</a>
</span><span class="comment">*</span><span class="comment">                =N+4: error return from <a name="DORGQR.181"></a><a href="dorgqr.f.html#DORGQR.1">DORGQR</a>
</span><span class="comment">*</span><span class="comment">                =N+5: error return from <a name="DGGHRD.182"></a><a href="dgghrd.f.html#DGGHRD.1">DGGHRD</a>
</span><span class="comment">*</span><span class="comment">                =N+6: error return from <a name="DHGEQZ.183"></a><a href="dhgeqz.f.html#DHGEQZ.1">DHGEQZ</a> (other than failed
</span><span class="comment">*</span><span class="comment">                                                iteration)
</span><span class="comment">*</span><span class="comment">                =N+7: error return from <a name="DTGEVC.185"></a><a href="dtgevc.f.html#DTGEVC.1">DTGEVC</a>
</span><span class="comment">*</span><span class="comment">                =N+8: error return from <a name="DGGBAK.186"></a><a href="dggbak.f.html#DGGBAK.1">DGGBAK</a> (computing VL)
</span><span class="comment">*</span><span class="comment">                =N+9: error return from <a name="DGGBAK.187"></a><a href="dggbak.f.html#DGGBAK.1">DGGBAK</a> (computing VR)
</span><span class="comment">*</span><span class="comment">                =N+10: error return from <a name="DLASCL.188"></a><a href="dlascl.f.html#DLASCL.1">DLASCL</a> (various calls)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Further Details
</span><span class="comment">*</span><span class="comment">  ===============
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Balancing
</span><span class="comment">*</span><span class="comment">  ---------
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  This driver calls <a name="DGGBAL.196"></a><a href="dggbal.f.html#DGGBAL.1">DGGBAL</a> to both permute and scale rows and columns
</span><span class="comment">*</span><span class="comment">  of A and B.  The permutations PL and PR are chosen so that PL*A*PR
</span><span class="comment">*</span><span class="comment">  and PL*B*R will be upper triangular except for the diagonal blocks
</span><span class="comment">*</span><span class="comment">  A(i:j,i:j) and B(i:j,i:j), with i and j as close together as
</span><span class="comment">*</span><span class="comment">  possible.  The diagonal scaling matrices DL and DR are chosen so
</span><span class="comment">*</span><span class="comment">  that the pair  DL*PL*A*PR*DR, DL*PL*B*PR*DR have elements close to
</span><span class="comment">*</span><span class="comment">  one (except for the elements that start out zero.)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  After the eigenvalues and eigenvectors of the balanced matrices
</span><span class="comment">*</span><span class="comment">  have been computed, <a name="DGGBAK.205"></a><a href="dggbak.f.html#DGGBAK.1">DGGBAK</a> transforms the eigenvectors back to what
</span><span class="comment">*</span><span class="comment">  they would have been (in perfect arithmetic) if they had not been
</span><span class="comment">*</span><span class="comment">  balanced.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Contents of A and B on Exit
</span><span class="comment">*</span><span class="comment">  -------- -- - --- - -- ----
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  If any eigenvectors are computed (either JOBVL='V' or JOBVR='V' or
</span><span class="comment">*</span><span class="comment">  both), then on exit the arrays A and B will contain the real Schur
</span><span class="comment">*</span><span class="comment">  form[*] of the &quot;balanced&quot; versions of A and B.  If no eigenvectors
</span><span class="comment">*</span><span class="comment">  are computed, then only the diagonal blocks will be correct.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  [*] See <a name="DHGEQZ.217"></a><a href="dhgeqz.f.html#DHGEQZ.1">DHGEQZ</a>, <a name="DGEGS.217"></a><a href="dgegs.f.html#DGEGS.1">DGEGS</a>, or read the book &quot;Matrix Computations&quot;,
</span><span class="comment">*</span><span class="comment">      by Golub &amp; van Loan, pub. by Johns Hopkins U. Press.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  =====================================================================
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Parameters ..
</span>      DOUBLE PRECISION   ZERO, ONE
      PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      LOGICAL            ILIMIT, ILV, ILVL, ILVR, LQUERY
      CHARACTER          CHTEMP
      INTEGER            ICOLS, IHI, IINFO, IJOBVL, IJOBVR, ILEFT, ILO,
     $                   IN, IRIGHT, IROWS, ITAU, IWORK, JC, JR, LOPT,
     $                   LWKMIN, LWKOPT, NB, NB1, NB2, NB3
      DOUBLE PRECISION   ABSAI, ABSAR, ABSB, ANRM, ANRM1, ANRM2, BNRM,
     $                   BNRM1, BNRM2, EPS, ONEPLS, SAFMAX, SAFMIN,
     $                   SALFAI, SALFAR, SBETA, SCALE, TEMP
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Local Arrays ..
</span>      LOGICAL            LDUMMA( 1 )
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Subroutines ..
</span>      EXTERNAL           <a name="DGEQRF.240"></a><a href="dgeqrf.f.html#DGEQRF.1">DGEQRF</a>, <a name="DGGBAK.240"></a><a href="dggbak.f.html#DGGBAK.1">DGGBAK</a>, <a name="DGGBAL.240"></a><a href="dggbal.f.html#DGGBAL.1">DGGBAL</a>, <a name="DGGHRD.240"></a><a href="dgghrd.f.html#DGGHRD.1">DGGHRD</a>, <a name="DHGEQZ.240"></a><a href="dhgeqz.f.html#DHGEQZ.1">DHGEQZ</a>, <a name="DLACPY.240"></a><a href="dlacpy.f.html#DLACPY.1">DLACPY</a>,
     $                   <a name="DLASCL.241"></a><a href="dlascl.f.html#DLASCL.1">DLASCL</a>, <a name="DLASET.241"></a><a href="dlaset.f.html#DLASET.1">DLASET</a>, <a name="DORGQR.241"></a><a href="dorgqr.f.html#DORGQR.1">DORGQR</a>, <a name="DORMQR.241"></a><a href="dormqr.f.html#DORMQR.1">DORMQR</a>, <a name="DTGEVC.241"></a><a href="dtgevc.f.html#DTGEVC.1">DTGEVC</a>, <a name="XERBLA.241"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. External Functions ..
</span>      LOGICAL            <a name="LSAME.244"></a><a href="lsame.f.html#LSAME.1">LSAME</a>
      INTEGER            <a name="ILAENV.245"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>
      DOUBLE PRECISION   <a name="DLAMCH.246"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="DLANGE.246"></a><a href="dlange.f.html#DLANGE.1">DLANGE</a>
      EXTERNAL           <a name="LSAME.247"></a><a href="lsame.f.html#LSAME.1">LSAME</a>, <a name="ILAENV.247"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>, <a name="DLAMCH.247"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>, <a name="DLANGE.247"></a><a href="dlange.f.html#DLANGE.1">DLANGE</a>
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC          ABS, INT, MAX
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Executable Statements ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Decode the input arguments
</span><span class="comment">*</span><span class="comment">
</span>      IF( <a name="LSAME.256"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVL, <span class="string">'N'</span> ) ) THEN
         IJOBVL = 1
         ILVL = .FALSE.
      ELSE IF( <a name="LSAME.259"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVL, <span class="string">'V'</span> ) ) THEN
         IJOBVL = 2
         ILVL = .TRUE.
      ELSE
         IJOBVL = -1
         ILVL = .FALSE.
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( <a name="LSAME.267"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVR, <span class="string">'N'</span> ) ) THEN
         IJOBVR = 1
         ILVR = .FALSE.
      ELSE IF( <a name="LSAME.270"></a><a href="lsame.f.html#LSAME.1">LSAME</a>( JOBVR, <span class="string">'V'</span> ) ) THEN
         IJOBVR = 2
         ILVR = .TRUE.
      ELSE
         IJOBVR = -1
         ILVR = .FALSE.
      END IF
      ILV = ILVL .OR. ILVR
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Test the input arguments
</span><span class="comment">*</span><span class="comment">
</span>      LWKMIN = MAX( 8*N, 1 )
      LWKOPT = LWKMIN
      WORK( 1 ) = LWKOPT
      LQUERY = ( LWORK.EQ.-1 )
      INFO = 0
      IF( IJOBVL.LE.0 ) THEN
         INFO = -1
      ELSE IF( IJOBVR.LE.0 ) THEN
         INFO = -2
      ELSE IF( N.LT.0 ) THEN
         INFO = -3
      ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
         INFO = -5
      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
         INFO = -7
      ELSE IF( LDVL.LT.1 .OR. ( ILVL .AND. LDVL.LT.N ) ) THEN
         INFO = -12
      ELSE IF( LDVR.LT.1 .OR. ( ILVR .AND. LDVR.LT.N ) ) THEN
         INFO = -14
      ELSE IF( LWORK.LT.LWKMIN .AND. .NOT.LQUERY ) THEN
         INFO = -16
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( INFO.EQ.0 ) THEN
         NB1 = <a name="ILAENV.305"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 1, <span class="string">'<a name="DGEQRF.305"></a><a href="dgeqrf.f.html#DGEQRF.1">DGEQRF</a>'</span>, <span class="string">' '</span>, N, N, -1, -1 )
         NB2 = <a name="ILAENV.306"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 1, <span class="string">'<a name="DORMQR.306"></a><a href="dormqr.f.html#DORMQR.1">DORMQR</a>'</span>, <span class="string">' '</span>, N, N, N, -1 )
         NB3 = <a name="ILAENV.307"></a><a href="ilaenv.f.html#ILAENV.1">ILAENV</a>( 1, <span class="string">'<a name="DORGQR.307"></a><a href="dorgqr.f.html#DORGQR.1">DORGQR</a>'</span>, <span class="string">' '</span>, N, N, N, -1 )
         NB = MAX( NB1, NB2, NB3 )
         LOPT = 2*N + MAX( 6*N, N*( NB+1 ) )
         WORK( 1 ) = LOPT
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( INFO.NE.0 ) THEN
         CALL <a name="XERBLA.314"></a><a href="xerbla.f.html#XERBLA.1">XERBLA</a>( <span class="string">'<a name="DGEGV.314"></a><a href="dgegv.f.html#DGEGV.1">DGEGV</a> '</span>, -INFO )
         RETURN
      ELSE IF( LQUERY ) THEN
         RETURN
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Quick return if possible
</span><span class="comment">*</span><span class="comment">
</span>      IF( N.EQ.0 )
     $   RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Get machine constants
</span><span class="comment">*</span><span class="comment">
</span>      EPS = <a name="DLAMCH.327"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'E'</span> )*<a name="DLAMCH.327"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'B'</span> )
      SAFMIN = <a name="DLAMCH.328"></a><a href="dlamch.f.html#DLAMCH.1">DLAMCH</a>( <span class="string">'S'</span> )
      SAFMIN = SAFMIN + SAFMIN
      SAFMAX = ONE / SAFMIN
      ONEPLS = ONE + ( 4*EPS )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Scale A
</span><span class="comment">*</span><span class="comment">
</span>      ANRM = <a name="DLANGE.335"></a><a href="dlange.f.html#DLANGE.1">DLANGE</a>( <span class="string">'M'</span>, N, N, A, LDA, WORK )
      ANRM1 = ANRM
      ANRM2 = ONE
      IF( ANRM.LT.ONE ) THEN
         IF( SAFMAX*ANRM.LT.ONE ) THEN
            ANRM1 = SAFMIN
            ANRM2 = SAFMAX*ANRM
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( ANRM.GT.ZERO ) THEN
         CALL <a name="DLASCL.346"></a><a href="dlascl.f.html#DLASCL.1">DLASCL</a>( <span class="string">'G'</span>, -1, -1, ANRM, ONE, N, N, A, LDA, IINFO )
         IF( IINFO.NE.0 ) THEN
            INFO = N + 10
            RETURN
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Scale B
</span><span class="comment">*</span><span class="comment">
</span>      BNRM = <a name="DLANGE.355"></a><a href="dlange.f.html#DLANGE.1">DLANGE</a>( <span class="string">'M'</span>, N, N, B, LDB, WORK )
      BNRM1 = BNRM
      BNRM2 = ONE
      IF( BNRM.LT.ONE ) THEN
         IF( SAFMAX*BNRM.LT.ONE ) THEN
            BNRM1 = SAFMIN
            BNRM2 = SAFMAX*BNRM
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( BNRM.GT.ZERO ) THEN
         CALL <a name="DLASCL.366"></a><a href="dlascl.f.html#DLASCL.1">DLASCL</a>( <span class="string">'G'</span>, -1, -1, BNRM, ONE, N, N, B, LDB, IINFO )
         IF( IINFO.NE.0 ) THEN
            INFO = N + 10
            RETURN
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Permute the matrix to make it more nearly triangular
</span><span class="comment">*</span><span class="comment">     Workspace layout:  (8*N words -- &quot;work&quot; requires 6*N words)
</span><span class="comment">*</span><span class="comment">        left_permutation, right_permutation, work...
</span><span class="comment">*</span><span class="comment">
</span>      ILEFT = 1
      IRIGHT = N + 1
      IWORK = IRIGHT + N
      CALL <a name="DGGBAL.380"></a><a href="dggbal.f.html#DGGBAL.1">DGGBAL</a>( <span class="string">'P'</span>, N, A, LDA, B, LDB, ILO, IHI, WORK( ILEFT ),
     $             WORK( IRIGHT ), WORK( IWORK ), IINFO )
      IF( IINFO.NE.0 ) THEN
         INFO = N + 1
         GO TO 120
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Reduce B to triangular form, and initialize VL and/or VR
</span><span class="comment">*</span><span class="comment">     Workspace layout:  (&quot;work...&quot; must have at least N words)
</span><span class="comment">*</span><span class="comment">        left_permutation, right_permutation, tau, work...
</span><span class="comment">*</span><span class="comment">
</span>      IROWS = IHI + 1 - ILO
      IF( ILV ) THEN
         ICOLS = N + 1 - ILO
      ELSE
         ICOLS = IROWS
      END IF
      ITAU = IWORK
      IWORK = ITAU + IROWS
      CALL <a name="DGEQRF.399"></a><a href="dgeqrf.f.html#DGEQRF.1">DGEQRF</a>( IROWS, ICOLS, B( ILO, ILO ), LDB, WORK( ITAU ),
     $             WORK( IWORK ), LWORK+1-IWORK, IINFO )
      IF( IINFO.GE.0 )
     $   LWKOPT = MAX( LWKOPT, INT( WORK( IWORK ) )+IWORK-1 )
      IF( IINFO.NE.0 ) THEN
         INFO = N + 2
         GO TO 120
      END IF
<span class="comment">*</span><span class="comment">
</span>      CALL <a name="DORMQR.408"></a><a href="dormqr.f.html#DORMQR.1">DORMQR</a>( <span class="string">'L'</span>, <span class="string">'T'</span>, IROWS, ICOLS, IROWS, B( ILO, ILO ), LDB,
     $             WORK( ITAU ), A( ILO, ILO ), LDA, WORK( IWORK ),
     $             LWORK+1-IWORK, IINFO )
      IF( IINFO.GE.0 )
     $   LWKOPT = MAX( LWKOPT, INT( WORK( IWORK ) )+IWORK-1 )
      IF( IINFO.NE.0 ) THEN
         INFO = N + 3
         GO TO 120
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( ILVL ) THEN
         CALL <a name="DLASET.419"></a><a href="dlaset.f.html#DLASET.1">DLASET</a>( <span class="string">'Full'</span>, N, N, ZERO, ONE, VL, LDVL )
         CALL <a name="DLACPY.420"></a><a href="dlacpy.f.html#DLACPY.1">DLACPY</a>( <span class="string">'L'</span>, IROWS-1, IROWS-1, B( ILO+1, ILO ), LDB,
     $                VL( ILO+1, ILO ), LDVL )
         CALL <a name="DORGQR.422"></a><a href="dorgqr.f.html#DORGQR.1">DORGQR</a>( IROWS, IROWS, IROWS, VL( ILO, ILO ), LDVL,
     $                WORK( ITAU ), WORK( IWORK ), LWORK+1-IWORK,
     $                IINFO )
         IF( IINFO.GE.0 )
     $      LWKOPT = MAX( LWKOPT, INT( WORK( IWORK ) )+IWORK-1 )
         IF( IINFO.NE.0 ) THEN
            INFO = N + 4
            GO TO 120
         END IF
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( ILVR )
     $   CALL <a name="DLASET.434"></a><a href="dlaset.f.html#DLASET.1">DLASET</a>( <span class="string">'Full'</span>, N, N, ZERO, ONE, VR, LDVR )
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Reduce to generalized Hessenberg form
</span><span class="comment">*</span><span class="comment">
</span>      IF( ILV ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Eigenvectors requested -- work on whole matrix.
</span><span class="comment">*</span><span class="comment">
</span>         CALL <a name="DGGHRD.442"></a><a href="dgghrd.f.html#DGGHRD.1">DGGHRD</a>( JOBVL, JOBVR, N, ILO, IHI, A, LDA, B, LDB, VL,
     $                LDVL, VR, LDVR, IINFO )
      ELSE
         CALL <a name="DGGHRD.445"></a><a href="dgghrd.f.html#DGGHRD.1">DGGHRD</a>( <span class="string">'N'</span>, <span class="string">'N'</span>, IROWS, 1, IROWS, A( ILO, ILO ), LDA,
     $                B( ILO, ILO ), LDB, VL, LDVL, VR, LDVR, IINFO )
      END IF
      IF( IINFO.NE.0 ) THEN
         INFO = N + 5
         GO TO 120
      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Perform QZ algorithm
</span><span class="comment">*</span><span class="comment">     Workspace layout:  (&quot;work...&quot; must have at least 1 word)
</span><span class="comment">*</span><span class="comment">        left_permutation, right_permutation, work...
</span><span class="comment">*</span><span class="comment">
</span>      IWORK = ITAU
      IF( ILV ) THEN
         CHTEMP = <span class="string">'S'</span>
      ELSE
         CHTEMP = <span class="string">'E'</span>
      END IF
      CALL <a name="DHGEQZ.463"></a><a href="dhgeqz.f.html#DHGEQZ.1">DHGEQZ</a>( CHTEMP, JOBVL, JOBVR, N, ILO, IHI, A, LDA, B, LDB,
     $             ALPHAR, ALPHAI, BETA, VL, LDVL, VR, LDVR,
     $             WORK( IWORK ), LWORK+1-IWORK, IINFO )
      IF( IINFO.GE.0 )
     $   LWKOPT = MAX( LWKOPT, INT( WORK( IWORK ) )+IWORK-1 )
      IF( IINFO.NE.0 ) THEN
         IF( IINFO.GT.0 .AND. IINFO.LE.N ) THEN
            INFO = IINFO
         ELSE IF( IINFO.GT.N .AND. IINFO.LE.2*N ) THEN
            INFO = IINFO - N
         ELSE
            INFO = N + 6
         END IF
         GO TO 120
      END IF
<span class="comment">*</span><span class="comment">
</span>      IF( ILV ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Compute Eigenvectors  (<a name="DTGEVC.481"></a><a href="dtgevc.f.html#DTGEVC.1">DTGEVC</a> requires 6*N words of workspace)
</span><span class="comment">*</span><span class="comment">
</span>         IF( ILVL ) THEN
            IF( ILVR ) THEN
               CHTEMP = <span class="string">'B'</span>
            ELSE
               CHTEMP = <span class="string">'L'</span>
            END IF
         ELSE
            CHTEMP = <span class="string">'R'</span>
         END IF
<span class="comment">*</span><span class="comment">
</span>         CALL <a name="DTGEVC.493"></a><a href="dtgevc.f.html#DTGEVC.1">DTGEVC</a>( CHTEMP, <span class="string">'B'</span>, LDUMMA, N, A, LDA, B, LDB, VL, LDVL,
     $                VR, LDVR, N, IN, WORK( IWORK ), IINFO )
         IF( IINFO.NE.0 ) THEN
            INFO = N + 7
            GO TO 120
         END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Undo balancing on VL and VR, rescale
</span><span class="comment">*</span><span class="comment">
</span>         IF( ILVL ) THEN
            CALL <a name="DGGBAK.503"></a><a href="dggbak.f.html#DGGBAK.1">DGGBAK</a>( <span class="string">'P'</span>, <span class="string">'L'</span>, N, ILO, IHI, WORK( ILEFT ),
     $                   WORK( IRIGHT ), N, VL, LDVL, IINFO )
            IF( IINFO.NE.0 ) THEN
               INFO = N + 8
               GO TO 120
            END IF
            DO 50 JC = 1, N
               IF( ALPHAI( JC ).LT.ZERO )
     $            GO TO 50
               TEMP = ZERO
               IF( ALPHAI( JC ).EQ.ZERO ) THEN
                  DO 10 JR = 1, N
                     TEMP = MAX( TEMP, ABS( VL( JR, JC ) ) )
   10             CONTINUE
               ELSE
                  DO 20 JR = 1, N
                     TEMP = MAX( TEMP, ABS( VL( JR, JC ) )+
     $                      ABS( VL( JR, JC+1 ) ) )
   20             CONTINUE
               END IF
               IF( TEMP.LT.SAFMIN )
     $            GO TO 50
               TEMP = ONE / TEMP
               IF( ALPHAI( JC ).EQ.ZERO ) THEN
                  DO 30 JR = 1, N
                     VL( JR, JC ) = VL( JR, JC )*TEMP
   30             CONTINUE
               ELSE
                  DO 40 JR = 1, N
                     VL( JR, JC ) = VL( JR, JC )*TEMP
                     VL( JR, JC+1 ) = VL( JR, JC+1 )*TEMP
   40             CONTINUE
               END IF
   50       CONTINUE
         END IF
         IF( ILVR ) THEN
            CALL <a name="DGGBAK.539"></a><a href="dggbak.f.html#DGGBAK.1">DGGBAK</a>( <span class="string">'P'</span>, <span class="string">'R'</span>, N, ILO, IHI, WORK( ILEFT ),
     $                   WORK( IRIGHT ), N, VR, LDVR, IINFO )
            IF( IINFO.NE.0 ) THEN
               INFO = N + 9
               GO TO 120
            END IF
            DO 100 JC = 1, N
               IF( ALPHAI( JC ).LT.ZERO )
     $            GO TO 100
               TEMP = ZERO
               IF( ALPHAI( JC ).EQ.ZERO ) THEN
                  DO 60 JR = 1, N
                     TEMP = MAX( TEMP, ABS( VR( JR, JC ) ) )
   60             CONTINUE
               ELSE
                  DO 70 JR = 1, N
                     TEMP = MAX( TEMP, ABS( VR( JR, JC ) )+
     $                      ABS( VR( JR, JC+1 ) ) )
   70             CONTINUE
               END IF
               IF( TEMP.LT.SAFMIN )
     $            GO TO 100
               TEMP = ONE / TEMP
               IF( ALPHAI( JC ).EQ.ZERO ) THEN
                  DO 80 JR = 1, N
                     VR( JR, JC ) = VR( JR, JC )*TEMP
   80             CONTINUE
               ELSE
                  DO 90 JR = 1, N
                     VR( JR, JC ) = VR( JR, JC )*TEMP
                     VR( JR, JC+1 ) = VR( JR, JC+1 )*TEMP
   90             CONTINUE
               END IF
  100       CONTINUE
         END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        End of eigenvector calculation
</span><span class="comment">*</span><span class="comment">
</span>      END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Undo scaling in alpha, beta
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Note: this does not give the alpha and beta for the unscaled
</span><span class="comment">*</span><span class="comment">     problem.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     Un-scaling is limited to avoid underflow in alpha and beta
</span><span class="comment">*</span><span class="comment">     if they are significant.
</span><span class="comment">*</span><span class="comment">
</span>      DO 110 JC = 1, N
         ABSAR = ABS( ALPHAR( JC ) )
         ABSAI = ABS( ALPHAI( JC ) )
         ABSB = ABS( BETA( JC ) )
         SALFAR = ANRM*ALPHAR( JC )
         SALFAI = ANRM*ALPHAI( JC )
         SBETA = BNRM*BETA( JC )
         ILIMIT = .FALSE.
         SCALE = ONE
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Check for significant underflow in ALPHAI
</span><span class="comment">*</span><span class="comment">
</span>         IF( ABS( SALFAI ).LT.SAFMIN .AND. ABSAI.GE.
     $       MAX( SAFMIN, EPS*ABSAR, EPS*ABSB ) ) THEN
            ILIMIT = .TRUE.
            SCALE = ( ONEPLS*SAFMIN / ANRM1 ) /
     $              MAX( ONEPLS*SAFMIN, ANRM2*ABSAI )
<span class="comment">*</span><span class="comment">
</span>         ELSE IF( SALFAI.EQ.ZERO ) THEN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">           If insignificant underflow in ALPHAI, then make the
</span><span class="comment">*</span><span class="comment">           conjugate eigenvalue real.
</span><span class="comment">*</span><span class="comment">
</span>            IF( ALPHAI( JC ).LT.ZERO .AND. JC.GT.1 ) THEN
               ALPHAI( JC-1 ) = ZERO
            ELSE IF( ALPHAI( JC ).GT.ZERO .AND. JC.LT.N ) THEN
               ALPHAI( JC+1 ) = ZERO
            END IF
         END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Check for significant underflow in ALPHAR
</span><span class="comment">*</span><span class="comment">
</span>         IF( ABS( SALFAR ).LT.SAFMIN .AND. ABSAR.GE.
     $       MAX( SAFMIN, EPS*ABSAI, EPS*ABSB ) ) THEN
            ILIMIT = .TRUE.
            SCALE = MAX( SCALE, ( ONEPLS*SAFMIN / ANRM1 ) /
     $              MAX( ONEPLS*SAFMIN, ANRM2*ABSAR ) )
         END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Check for significant underflow in BETA
</span><span class="comment">*</span><span class="comment">
</span>         IF( ABS( SBETA ).LT.SAFMIN .AND. ABSB.GE.
     $       MAX( SAFMIN, EPS*ABSAR, EPS*ABSAI ) ) THEN
            ILIMIT = .TRUE.
            SCALE = MAX( SCALE, ( ONEPLS*SAFMIN / BNRM1 ) /
     $              MAX( ONEPLS*SAFMIN, BNRM2*ABSB ) )
         END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Check for possible overflow when limiting scaling
</span><span class="comment">*</span><span class="comment">
</span>         IF( ILIMIT ) THEN
            TEMP = ( SCALE*SAFMIN )*MAX( ABS( SALFAR ), ABS( SALFAI ),
     $             ABS( SBETA ) )
            IF( TEMP.GT.ONE )
     $         SCALE = SCALE / TEMP
            IF( SCALE.LT.ONE )
     $         ILIMIT = .FALSE.
         END IF
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        Recompute un-scaled ALPHAR, ALPHAI, BETA if necessary.
</span><span class="comment">*</span><span class="comment">
</span>         IF( ILIMIT ) THEN
            SALFAR = ( SCALE*ALPHAR( JC ) )*ANRM
            SALFAI = ( SCALE*ALPHAI( JC ) )*ANRM
            SBETA = ( SCALE*BETA( JC ) )*BNRM
         END IF
         ALPHAR( JC ) = SALFAR
         ALPHAI( JC ) = SALFAI
         BETA( JC ) = SBETA
  110 CONTINUE
<span class="comment">*</span><span class="comment">
</span>  120 CONTINUE
      WORK( 1 ) = LWKOPT
<span class="comment">*</span><span class="comment">
</span>      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="DGEGV.663"></a><a href="dgegv.f.html#DGEGV.1">DGEGV</a>
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>
